import { getFileName } from '../../utils'
import { SettingNavCallback } from './contents/system/settingNav'

export const settingId = 'settings'


export interface NavItemInfo {
  name: string
  icon: string
  text: string
  active?: boolean
}

export interface SystemNavItemInfo {
  icon: string
  iconType?: string
  name: string
  text: string
  desc: string
  path: string
  control?: any
  content?: any
  isNav?: boolean
  expanded?: boolean
}

export interface ISettingContent {
  element: HTMLDivElement
  dispose(): void
}

export type SettingContentFunction = (onNavItemClick: SettingNavCallback) => ISettingContent

export interface SettingsChildrenInfo {
  icon: string
  iconType?: string
  text: string
  desc: string
}

export interface SettingsChildrenIndex {
  [key: string]: SettingsChildrenInfo
}

export interface SettingParentInfo {
  icon: string
  iconType?: string
  text: string,
  items?: SettingsChildrenIndex
}

interface SettingsInfoIndex {
  [key: string]: SettingParentInfo
}

export interface ISettingContentMap {
  content: SettingContentFunction
  children?: ISettingContentMapIndex
}

export interface ISettingContentMapIndex {
  [key: string]: ISettingContentMap
}

export const settingsInfo: SettingsInfoIndex = {
  system: {
    icon: 'imgs/icons/Desktop.png',
    iconType: 'image',
    text: '系统',
    items: {
      display: {
        icon: '',
        text: '屏幕',
        desc: '显示器、亮度、夜间模式、显示器配置文件'
      },
      sound: {
        icon: '',
        text: '声音',
        desc: '音量、输出、输入、声音设备'
      },
      noitification: {
        icon: '',
        text: '通知',
        desc: '来自应用和系统的通知，请勿打扰'
      },
      focusAssist: {
        icon: '',
        text: '专注',
        desc: '减少干扰'
      },
      powerAndBatery: {
        icon: '',
        text: '电源',
        desc: '屏幕和睡眠，电源模式'
      },
      storage: {
        icon: '',
        text: '存储',
        desc: '存储空间、驱动器、配置规则'
      },
    }
  },
  bluetoothAndDevice: {
    icon: 'imgs/icons/Misc/Bluetooth.png',
    text: '蓝牙和其他设备'
  },
  networkAndInternet: {
    icon: 'imgs/icons/Misc/wifi.png',
    text: '网络和 Intenet'
  },
  personalization: {
    icon: 'imgs/icons/Personalization.png',
    iconType: 'image',
    text: '个性化',
    items: {
      background: {
        icon: '',
        text: '背景',
        desc: '背景图像、颜色、幻灯片'
      },
      colors: {
        icon: '',
        text: '颜色',
        desc: '主题色、透明效果、颜色主题'
      },
      lockScreen: {
        icon: '',
        text: '锁屏界面',
        desc: '锁定屏幕图像、应用和动画'
      },
      theme: {
        icon: '',
        text: '主题',
        desc: '安装、创建、管理'
      },
      font: {
        icon: '',
        text: '字体',
        desc: '安装、管理'
      },
      start: {
        icon: '',
        text: '开始',
        desc: '最近使用的应用和项目、文件夹'
      },
      taskbar: {
        icon: '',
        text: '任务栏',
        desc: '任务栏行为，系统固定项'
      }
    }
  },
  apps: {
    icon: 'imgs/icons/Misc/15.png',
    text: '应用'
  },
  accounts: {
    icon: 'imgs/icons/Users.png',
    iconType: 'image',
    text: '账户'
  },
  timeAndLanguage: {
    icon: 'imgs/icons/Misc/Time And Language.png',
    text: '时间和语言'
  },
  gaming: {
    icon: 'imgs/icons/Misc/Gaming.png',
    text: '游戏'
  },
  accessibility: {
    icon: 'imgs/icons/Help.png',
    text: '辅助功能'
  },
  privacyAndSecurity: {
    icon: 'imgs/icons/Security.png',
    text: '隐私和安全性'
  },
  windowUpdate: {
    icon: 'imgs/icons/Emblems/1401.png',
    text: 'GXG.FAN 更新'
  }
}

export const navItems: Array<NavItemInfo> = Object.keys(settingsInfo).map((key, index) => {
  const info = settingsInfo[key]

  let obj = Object.create(null)

  obj = {
    name: key,
    icon: info.icon,
    text: info.text
  }

  if (index === 0) {
    obj.active = true
  }

  return obj
})


export function getThumbnailFromImage(path: string) {
  return 'imgs/Wallpapers/Thumbnails/' + getFileName(path)
}
